
clear all
set more off
cd C:\Data\US_stata\6614\UKDA-6614-stata12_se\stata12_se\

use a_indresp

* Only look at full interviews, in fully cooperating households .

keep if a_ioutcome == 11
keep if a_hhresp_dv == 1
sum pidp

keep pidp a_hidp a_pno a_sex a_dvage a_mvever a_mvyr a_mlstat a_ukborn a_plbornc a_yr2uk4 a_citzn1 ///
 a_citzn2 a_citzn3 a_qfhigh a_pacob a_payruk a_payruk1 a_macob a_mayruk a_mayruk1 a_pgprob a_pgmrob ///
 a_natid1 a_natid2 a_natid3 a_natid4 a_natid5 a_natid6 a_natid97 a_racel a_paid a_spaid a_maid a_smaid ///
 a_britid a_englang a_engspk a_spkdif a_engtel a_teldif a_engread a_readdif a_engform a_formdif a_oprlg ///
 a_oprlg0 a_oprlg0ni a_oprlg1 a_nirel a_niact a_oprlg2 a_oprlg3 a_mabroad a_mnotherc a_moveage a_mlivedist ///
 a_lcmarm a_lcmary4 a_mpno a_lcmcoh a_lcmcbm a_lcmcby4 a_lcmspm a_lcmspy4 a_nmar a_lcoh a_lncoh a_sf1 ///
 a_jbseg_dv a_jbrgsc_dv a_jbsect a_jbsectpub a_jbhrs a_jbttwt a_basrest a_lvrel1 a_lvrel2 a_lvrel3 ///
 a_lvrel4 a_lvrel5 a_lvrel6 a_lvrel7 a_lvrel8 a_lvrel96 a_maage a_paage a_parmar a_ohch16 a_seekid a_wekid ///
 a_finnow a_finfut a_vote1 a_vote2 a_vote3 a_vote4 a_vote5 a_vote6 a_envhabit1 a_envhabit2 a_envhabit3 ///
 a_envhabit4 a_envhabit5 a_envhabit6 a_envhabit7 a_envhabit8 a_envhabit9 a_envhabit10 a_envhabit11 a_drive ///
 a_mobuse a_netuse a_nch14resp a_nnatch a_nadoptch a_vote3_all a_vote4_all a_prfitb a_prfitbw a_prfitba ///
 a_country a_marstat a_livesp a_livewith a_employ a_respf16 a_respm16 a_ioutcome a_ivfio a_hhresp_dv ///
 a_agegr10_dv a_mastat_dv a_swemwbs_dv a_hiqual_dv a_jbft_dv a_jbnssec5_dv a_fimnlabgrs_dv ///
 a_fimngrs_dv a_gor_dv a_urban_dv a_indinus_xw 

rename a_indinus_xw a_weight_xs
gen a_wave = 1

sort pidp
compress

save usoc_w_a, replace


clear all
use b_indresp
* Only look at full interviews, in fully cooperating households .

keep if b_ioutcome == 11
keep if b_hhresp_dv == 1

keep pidp b_hidp b_pno b_sex b_dvage b_mvever b_mvyr b_mlstat b_ukborn b_plbornc b_yr2uk4 b_citzn1 ///
 b_citzn2 b_citzn3 b_qfhigh b_pacob b_macob  ///
 b_natid1 b_natid2 b_natid3 b_natid4 b_natid5 b_natid6 b_natid97 b_racel  ///
 b_oprlg ///
 b_oprlg0 b_oprlg0ni b_oprlg1 b_nirel b_niact  ///
 b_jbseg_dv b_jbrgsc_dv b_jbsect b_jbsectpub b_jbhrs b_jbttwt b_basrest ///
 b_finnow b_finfut b_vote1 b_vote2 b_vote3 b_vote4 b_vote5 b_vote6 ///
 b_vote7 b_vote8 ///
 b_volun b_volfreq b_volhrs b_chargv b_charfreq b_charam ///
 b_hubuys b_hufrys b_humops b_huiron b_hupots b_hudiy  b_husits b_huboss b_howlng ///
 b_drive ///
 b_mobuse b_netuse b_nch14resp b_nnatch b_nadoptch b_vote3_all b_vote4_all b_prfitb b_prfitbw b_prfitba ///
 b_country b_marstat b_livesp b_livewith b_employ b_respf16 b_respm16 b_ioutcome b_ivfio b_hhresp_dv ///
 b_agegr10_dv b_mastat_dv b_hiqual_dv b_jbft_dv b_jbnssec5_dv b_fimnlabgrs_dv ///
 b_fimngrs_dv b_gor_dv b_urban_dv b_indinus_xw 


 
rename b_indinus_xw b_weight_xs
gen b_wave=2
sort pidp
compress

save usoc_w_b, replace



clear all
use c_indresp

keep pidp c_hidp c_pno c_sex c_dvage c_mvever c_mvyr c_mlstat c_ukborn c_plbornc c_yr2uk4 c_citzn1 ///
 c_citzn2 c_citzn3 c_qfhigh c_pacob c_macob  ///
 c_natid1 c_natid2 c_natid3 c_natid4 c_natid5 c_natid6 c_natid97 c_racel  ///
 c_oprlg ///
 c_oprlg0 c_oprlg0ni c_oprlg1 c_nirel c_niact  ///
 c_jbseg_dv c_jbrgsc_dv c_jbsect c_jbsectpub c_jbhrs c_jbttwt c_basrest ///
 c_finnow c_finfut c_vote1 c_vote2 c_vote3 c_vote4 c_vote5 c_vote6 ///
 c_poleff1 c_poleff2 c_poleff3 c_poleff4 ///
 c_newsmain c_paperm2 c_tvm2 c_netm2 c_tvhours ///
 c_drive ///
 c_mobuse c_netuse c_nch14resp c_nnatch c_nadoptch c_vote3_all c_vote4_all c_prfitb c_prfitbw c_prfitba ///
 c_country c_marstat c_livesp c_livewith c_employ c_respf16 c_respm16 c_ioutcome c_ivfio c_hhresp_dv ///
 c_agegr10_dv c_mastat_dv c_hiqual_dv c_jbft_dv c_jbnssec5_dv c_fimnlabgrs_dv ///
 c_fimngrs_dv c_gor_dv c_urban_dv c_indinub_xw 
 

label define c_newsmain2 -9 "missing" -8 "inapplicable" -7 "proxy" -2 "refusal" -1 "don't know" ///
1 "Personal experience"  ///
2 "The experiences of relatives and/or friends" ///
3 "General word of mouth or information from other people" ///
4 "National newspapers" ///
5 "Local newspapers" ///
6 "Television" ///
7 "Radio" ///
8 "Internet or the world-wide-web" ///
9 "Government publications" ///
10 "Books" ///
11 "School, college or evening class" ///
12 "Somewhere else" ///

label values c_newsmain c_newsmain2
tab1 c_newsmain

rename c_indinub_xw c_weight_xs
gen c_wave=3
sort pidp
compress

save usoc_w_c, replace


* Create a merged data in wide format
clear all
use usoc_w_a
merge 1:1 pidp using usoc_w_b
rename _merge _merge_a_b
merge 1:1 pidp using usoc_w_c
rename _merge _merge_ab_c

tab1 _merge_ab_c _merge_ab

gen partpatt = .
label var partpatt "Participation pattern"
replace partpatt=1 if a_wave==1 & b_wave==2 & c_wave==3
replace partpatt=2 if a_wave==1 & b_wave==2 & c_wave==.
replace partpatt=3 if a_wave==1 & b_wave==. & c_wave==3
replace partpatt=4 if a_wave==1 & b_wave==. & c_wave==.
replace partpatt=5 if a_wave==. & b_wave==2 & c_wave==3
replace partpatt=6 if a_wave==. & b_wave==2 & c_wave==.
replace partpatt=7 if a_wave==. & b_wave==. & c_wave==3

label define partpatt 1 "111" 2 "11-" 3 "1-1" 4 "1--" 5 "-11" 6 "-1-" 7 "--1" 
label val partpatt partpatt
tab1 partpatt

compress
save usoc_w_abc_wide, replace

* create a long format dataset

use usoc_w_a
renpfix a_
save usoc_w_1,replace

use usoc_w_b
renpfix b_
save usoc_w_2,replace

use usoc_w_c
renpfix c_
save usoc_w_3,replace

clear all
use usoc_w_1
append using usoc_w_2 usoc_w_3 

compress
save usoc_w_123_long, replace

